<?php
	require_once("../Database/DBConnector.php");
	
	class Event
	{
		private $h;
		private $db;
		private $eventsTable;
		
		public function Event($db, $evTable)
		{
			$this->db = $db;
			$this->eventsTable = $evTable;
		}
		
		public function Load($id)
		{
			$res = $this->db->Query("SELECT * FROM ".$this->eventsTable." WHERE EventID=$id");
			$this->{'h'} = $res[0];
		}
		
		public function Update()
		{
			$sql = sprintf("UPDATE ".$this->eventsTable." SET EventHeader=".$this->{'h'}->EventHeader.
			", EventText=".$this->{'h'}->EventText.", EventType=".$this->{'h'}->EventType.
			", EventStart=".$this->{'h'}->EventStart.", EventEnd=".$this->{'h'}->EventEnd.
			" WHERE EventID=".$this->{'h'}->EventID);
			$res = $this->db->Query($sql);
		}
		
		public function Delete($table, $id)
		{
			$res = $this->db->Query("DELETE FROM ".$this->eventsTable." WHERE EventID=$id");
		}
		
		public function __get($varname)
		{
			return $this->{'h'}->$varname;
		}
		
		public function __set($varname, $value)
		{
			$this->{'h'}->$varname = $value;
		}
	}
?>
